home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig18_03.jar
/
Ch18
/
Fig18_03
/
Fig18_03.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1997-11-10
|
621b
|
26 lines
// Fig. 18.3: fig18_03.cpp
// Using command-line arguments
#include <iostream.h>
#include <fstream.h>
int main( int argc, char *argv[] )
{
if ( argc != 3 )
cout << "Usage: copy infile outfile" << endl;
else {
ifstream inFile( argv[ 1 ], ios::in );
if ( !inFile )
cout << argv[ 1 ] << " could not be opened" << endl;
ofstream outFile( argv[ 2 ], ios::out );
if ( !outFile )
cout << argv[ 2 ] << " could not be opened" << endl;
while ( !inFile.eof() )
outFile.put( static_cast< char >( inFile.get() ) );
}
return 0;
}